package ro.myApp.articles.entities;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import ro.myApp.security.entities.Role;

@Entity
@DiscriminatorValue("ART")
public class Article extends Publication {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4764994675948286624L;

	private boolean accessPublic;
	
	@OneToOne(fetch=FetchType.EAGER)
	private Role accessRole;
	
	@OneToMany(cascade=CascadeType.REMOVE, fetch=FetchType.LAZY, mappedBy="publication")
	private List<Review> reviews = new LinkedList<Review>();
	
	@OneToMany(cascade=CascadeType.REMOVE, fetch=FetchType.LAZY, mappedBy="publication")
	private List<Translation> translations = new LinkedList<Translation>();
	
	public List<Review> getReviews() {
		return reviews;
	}
	
	public void setReviews(List<Review> reviews) {
		this.reviews = reviews;
	}
	
	public List<Translation> getTranslations() {
		return translations;
	}
	
	public void setTranslations(List<Translation> translations) {
		this.translations = translations;
	}

	public void setAccessPublic(boolean accessPublic) {
		this.accessPublic = accessPublic;
	}

	public boolean isAccessPublic() {
		return accessPublic;
	}

	public void setAccessRole(Role accessRole) {
		this.accessRole = accessRole;
	}

	public Role getAccessRole() {
		return accessRole;
	}
	
}